package com.zmn.mcc.services.impl.role;

import com.zmn.mcc.model.entity.role.McRolePermit;
import com.zmn.mcc.persistence.interfaces.role.RolePermitDao;
import com.zmn.mcc.services.interfaces.role.RolePermitService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author heguanghua
 * @since 2020/04/14 21:41
 */
@Service
public class RolePermitServiceImpl implements RolePermitService {

    @Resource
    private RolePermitDao rolePermitDao;


    @Override
    public McRolePermit findByKey(Integer roleId, Integer permitId) {
        McRolePermit rolePermit = new McRolePermit();
        rolePermit.setRoleId(roleId);
        rolePermit.setPermitId(permitId);
        return this.findByKey(rolePermit);
    }
    @Override
    public McRolePermit findByKey(McRolePermit rolePermit) {
        return rolePermitDao.findByKey(rolePermit);
    }

    @Override
    public List<Integer> listPermitIdByRoleId(Integer roleId) {
        return rolePermitDao.listPermitIdByRoleId(roleId);
    }

    @Override
    public List<Integer> listPermitIdByRoleIds(List<Integer> roleIds) {
        return rolePermitDao.listPermitIdByRoleIds(roleIds);
    }

    @Override
    public List<Integer> listPermitIdByStaffId(Integer staffId) {
        return rolePermitDao.listPermitIdByStaffId(staffId);
    }

    @Override
    public List<McRolePermit> listPage(Integer startIndex, Integer pageSize) {

        return rolePermitDao.listPage(startIndex, pageSize);
    }

    @Override
    public Integer countByQuery(McRolePermit rolePermit) {
        return rolePermitDao.countByQuery(rolePermit);
    }



    @Override
    public Integer insert(McRolePermit rolePermit) {
        return rolePermitDao.insert(rolePermit);
    }
    
    @Override
    public Integer insertByBatch(List<McRolePermit> rolePermites) {
        return rolePermitDao.insertByBatch(rolePermites);
    }



    @Override
    public Integer deleteByKey(Integer roleId, Integer permitId) {
        McRolePermit rolePermit = new McRolePermit();
        rolePermit.setRoleId(roleId);
        rolePermit.setPermitId(permitId);
        return this.deleteByKey(rolePermit);
    }
    @Override
    public Integer deleteByKey(McRolePermit rolePermit) {
        return rolePermitDao.deleteByKey(rolePermit);
    }
    
    @Override
    public Integer deleteByRoleId(Integer roleId) {
        McRolePermit rolePermit = new McRolePermit();
        rolePermit.setRoleId(roleId);
        return this.deleteByQuery(rolePermit);
    }
    @Override
    public Integer deleteByPermitId(Integer permitId) {
        McRolePermit rolePermit = new McRolePermit();
        rolePermit.setPermitId(permitId);
        return this.deleteByQuery(rolePermit);
    }
    @Override
    public Integer deleteByQuery(McRolePermit rolePermit) {
        return rolePermitDao.deleteByQuery(rolePermit);
    }
}
